package co.baiku.boot.common.exception;

import org.springframework.http.HttpStatus;

public class AjavaerException extends RuntimeException {
    private HttpStatus httpStatus;
    private int code;

    public static AjavaerException of(String message) {
        return new AjavaerException(message);
    }

    public static AjavaerException of(HttpStatus httpStatus, String message) {
        return new AjavaerException(httpStatus, message);
    }

    public static AjavaerException of(HttpStatus httpStatus, int code, String message) {
        return new AjavaerException(httpStatus, code, message);
    }

    public AjavaerException(String message) {
        this(HttpStatus.BAD_REQUEST, message);
    }

    public AjavaerException(HttpStatus httpStatus, String message) {
        this(httpStatus, httpStatus.value(), message);
    }

    public AjavaerException(HttpStatus httpStatus, int code, String message) {
        super(message);
        this.code = code;
        this.httpStatus = httpStatus;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
